{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tutor Magic in IPython\n",
    "\n",
    "This notebook demonstrates the %%tutor magic as used in IPython notebook.\n",
    "\n",
    "First, you'll need the following installed:\n",
    "\n",
    "1. IPython/Jupyter\n",
    "2. [Metakernel](https://github.com/Calysto/metakernel)\n",
    "\n",
    "Next, you'll need to use the magics in IPython:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from metakernel import register_ipython_magics\n",
    "register_ipython_magics()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally, put a %%tutor at the top of any cell with Python code, and watch the visualization:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <iframe\n",
       "            width=\"100%\"\n",
       "            height=\"500\"\n",
       "            src=\"https://pythontutor.com/iframe-embed.html#code=%0Amylist%20%3D%20%5B%5D%0A%0Afor%20i%20in%20range%2810%29%3A%0A%20%20%20%20mylist.append%28i%20%2A%2A%202%29&origin=opt-frontend.js&cumulative=false&heapPrimitives=false&textReferences=false&py=3&rawInputLstJSON=%5B%5D&curInstr=0&codeDivWidth=350&codeDivHeight=400\"\n",
       "            frameborder=\"0\"\n",
       "            allowfullscreen\n",
       "        ></iframe>\n",
       "        "
      ],
      "text/plain": [
       "<IPython.lib.display.IFrame at 0x7fc3a9ee73c8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%tutor\n",
    "\n",
    "mylist = []\n",
    "\n",
    "for i in range(10):\n",
    "    mylist.append(i ** 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "Try it out!"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
